-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No elmi #15
No elmi #15
Conversation
Instead we use the approach of <rtfeldman/node-test-runner#442> from which I have taken a lot of inspiration for this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! 🎉
src/elmi.rs
Outdated
//! Basically a wrapper module for elmi-to-json for the time being. | ||
//! It reads the compiled .elmi files and extracts exposed tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of date comment?
Thanks a lot for this! If you don't mind, I'd prefer keeping my focus on finishing my current work on pubgrub-rs before switching back to this. Didn't know you'd port that so fast ^^. I'll probably not answer for a couple of weeks but feel free to continue discussing things here and making progress on that with @lydell until I join the discussion later :) |
It turned out to be quite straightforward! I guess the hard bit is speccing out the design space, "code being the easy part" after all. |
Thanks for the feedback :) I will let this sit for a couple weeks before starting the polishing just to give @mpizenberg some time. |
Just a small update to let you know I'll soon be able to review this, in the coming week very likely |
I have got the tree sitter ball rolling here elm-tooling/tree-sitter-elm#57 |
I've had a very quick look at the shape of the PR (not the logic yet). I feel like there are quite a few things that add noise because they are not directly related to the "no elmi" implementation. I'll try to extract those first in another PR to have a cleaner diff. "Make the change easy" as would say Dillon. I've another high-level question. The PR adds a build step using the "cc" crate. I suppose that's because of tree sitter. Is it going to be an issue for portability and to generate a statically compiled executable, preferably based on musl? Regarding the logic of the PR, would you mind do a summary of the necessary changes to what's existing and of what's new? |
I can have a go at that, mainly changes to
I can and will remove the dev dep on Saying that, there will still be a build step compiling the tree-sitter c code (just managed by the tree-sitter-elm crate rather than by us). The libraries created by the build step are statically linked into the executable and will use the configured compiler. Having a build step is 100% compatible with static musl binaries.
Certainly, watch this space... |
I've updated master and merged changes here to remove things unrelated to the PR. I'll take some time in the coming days to remind myself how elm-test-rs works (it has been some time ^^) to better understand what that PR brings. |
I've started by looking at the logic to get modules names. I'm wondering, would it be possible to extract modules names inside |
Do you mean extracting this part?
If so, just as a heads up: In node-test-runner we don’t use that module name. We just skip over it when parsing. Instead, we calculate the module name from the file path and source directories. This is because you can’t trust the module name – it can be wrong. In node-test-runner we don’t want to generate an |
I see. I thought there was no point double checking that this line is correct since the elm compiler also does it. In elm-test-rs we do this this just before parsing all tests: eprintln!("Compiling all test files ...");
compile(
&tests_root, // current_dir
&options.compiler, // compiler
"/dev/null", // output
&module_paths, // src
); where this basically calls |
Just just realizing that this would be a constant definition with a |
Is tree-sitter a parser generator? I mean, the tree-sitter-elm repo seems to mainly contain JS code, and yet it seems that the build step for the rust package only build two files, |
I don’t know much about tree-sitter but I managed to find this: https://tree-sitter.github.io/tree-sitter/
https://tree-sitter.github.io/tree-sitter/creating-parsers
|
src/parser.rs
Outdated
.map(|(file_path, source)| { | ||
let tree = { | ||
let mut parser = tree_sitter::Parser::new(); | ||
let language = tree_sitter_elm::language(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it make sense to have a much simpler parser able to parse modules headers. If that parser discovers exposing(..)
we switch to full file elm parsing.
It was quite some fun playing around the tree-sitter parser so I wanted to try its query system. I've rewritten |
I've moved all the code related to the query approach at the end of the file: Line 347 in 77b762e
One advantage I can see is that we could get rid of the |
I cleaned up by removing the tree-walking approach so that only the code for the query approach is left. It looks quite nice in my opinion but we can revert the commit if there are things you don't like. |
Hey! This is looking great! To apologise the product of free time and motivation that powers open source is looking very low for me at the moment and with Christmas coming it might stay that way to a while. I hadn't seen the query system, it looks much better than what I had. I always felt that that must be a better API but I couldn't find it, looks like it is queries! I like the new changes a lot :) feel free to run with this, I will try to chip in when I can :) |
I feel you, I have those time too ^^, thanks for the feedback @harrysarson and of course take the time you need, no pressure. |
@harrysarson @lydell Thanks a lot for this contribution! I'm about to merge this. Do you mind if I add the two of you in the |
Thanks! At this point, I’d rather not be listed as an author, since I have 0 commits and don’t know Rust. A few bits of comments and Elm and maybe test cases might be copied from stuff I wrote, but I don’t mind. I’m just happy to have been able to help! |
I wouldn't say no! Thank you that is very kind. |
Awesome, I'll add a commit on master directly 👍 |
Some notes from recent tests. The package elm-geometry is one such package that exhibits a duplicate test names error with elm-test-rs. Here is the result of me searching for one such conflicting name: $> rg "Every point on an arc is within its bounding box" tests/
tests/Tests/EllipticalArc2d.elm
159: "Every point on an arc is within its bounding box"
tests/Tests/Arc3d.elm
118: "Every point on an arc is within its bounding box"
tests/Tests/Arc2d.elm
183: "Every point on an arc is within its bounding box"
tests/Tests/EllipticalArc3d.elm
87: "Every point on an arc is within its bounding box" Also in my last few commits when I extracted |
Applying the work done in rtfeldman/node-test-runner#442 to the rust port of the test runner. Credit for the should go to @lydell as this is a port of their work.
Interested to hear feedback on: